<?php
include_once './Url.class.php';
$urlObj = new Url();

#echo $urlObj->getDec62(1);

$manger = new MongoDB\Driver\Manager("mongodb://127.0.0.1:27017/urldb");

/*
# 添加操作
$bulk = new MongoDB\Driver\BulkWrite(['ordered' => true]);
//$bulk->insert(['name'=>'iphone4']);
$bulk->insert(['name'=>'iphone5']);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 100);
$result = $manger->executeBulkWrite('urldb.test1',$bulk,$writeConcern);
*/

/*
# 查询操作
$filter = ['name'=>'iphone5'];
$options = [
    'limit' => 1,
    'projection'=>['_id'=>0]
];

$query = new MongoDb\Driver\Query($filter,$options);
$cursor = $manger->executeQuery('urldb.test',$query);

echo '<pre>';

#echo '<pre>';
#foreach($cursor as $r){
#    print_r($r);
#}

$list = $cursor->toArray();
print_r($list);
*/

/*$list = [

];
$obj = new MongoDB\Driver\Command($list);
$manger->executeCommand('test',$obj);*/

/*
# findAndModify命令的执行并得到结果写法
$cmd['findAndModify'] = 'cnt1';
$cmd['query'] = ['_id'=>1];
$cmd['update'] = ['$inc'=>['seq'=>1]];

$cmdobj = new MongoDB\Driver\Command($cmd);
$cursor = $manger->executeCommand('urldb',$cmdobj);
$response = $cursor->toArray()[0];
var_dump($response->value->seq);
*/